<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>网站后台管理系统</title>
  <link rel="stylesheet" href="/assets/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="/assets/fonts/iconfont.css">
  <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  <![endif]-->
  <link rel="stylesheet" href="/admin/css/common.css">
</head>
<body class="layui-layout-body admin-page">
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">修改密码</div>
          <div class="layui-card-body">
            <form class="layui-form" action="">

              <input type="hidden" name="id" value="{{userID}}">

              <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="password" lay-verify="pass" lay-reqtext="请输入新密码" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">6到16个字符</div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">确认新密码</label>
                <div class="layui-input-inline">
                  <input type="password" name="repassword" lay-verify="repass" lay-reqtext="请重复输入新密码" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <button class="layui-btn" lay-submit="" lay-filter="editPwd">确认修改</button>
                </div>
              </div>
            </form>
            
          </div>
        </div>
      </div>
    </div>
  </div>
<script src="/assets/layui/layui.js"></script>
<script type="text/javascript">
  layui.use(['form','jquery'], function(){
    var form = layui.form;
    var $ = jQuery = layui.$;


    form.verify({
      pass: [
        /^[\S]{6,16}$/
        ,'密码必须6到16位，且不能出现空格'
      ],
      repass:function(value){
        var pass = $('input[name=password]').val();
        if(value != pass){
          return '两次输入的密码不一致!';
        }
      }
    });

    form.on('submit(editPwd)', function(obj){
      $.post(
        './editPwd',
        obj.field,
        function(res){
        
          if(res.code == "0"){
            //登入成功的提示与跳转
            layer.msg('修改成功', {
              // offset: '15px',
              icon: 1,
              time: 1000
            });
          }else{
            layer.msg(res.msg, {
              // offset: '15px',
              icon: 2,
              time: 1000
            })
          }
        },
        'json'

      );
      return false;
    })
  });
</script>
</body>
</html>